package com.spic.business.alarm.controller;

import com.alibaba.fastjson.JSONArray;
import com.spic.business.alarm.domain.AlarmModel;
import com.spic.business.alarm.service.FloodControlService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 防汛告警Controller
 *
 * @author spic
 * @date 2022-03-03
 */
@RestController
@RequestMapping("/flood")
public class FloodController extends BaseController {
    @Autowired
    private FloodControlService floodControlService;

    /**
     * 定时任务新增告警
     */
    @PostMapping("/jobAdd")
    public AjaxResult monitorRainfall() {
        return toAjax(floodControlService.monitorRainfall());
    }

    @GetMapping("/list")
    public TableDataInfo list(AlarmModel alarmModel) {
        startPage();
        List<AlarmModel> list = floodControlService.selectAlarmList(alarmModel);
        return getDataTable(list);
    }
}
